<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>键盘事件</title>
</head>
<body>
	<textarea name = "" id ="text" cols ="30" rows="10"></textarea>
	<script type="text/javascript">
	//获取元素
	var text = document.getElementById('text');


	//键盘按下 onkeydown
	text.onkeydown =function()
	{
		console.log('down');
		//return false;	
	}

	//onkeypress
	text.onkeypress =function()
	{
		console.log('press');
		return false;
	}
	text.onkeyup =function()
	{
		console.log('up');
		//return false;
	}

	</script>
</body>
</html>